package com.example.chenduoyun.safe.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author by created chen cloudy 2018/9/7 15:40
 **/

public class SpUtils {
    private static SharedPreferences sp;

    public static void putBoolean(Context context, String key , boolean value){
        if(sp ==null) {
            sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        sp.edit().putBoolean(key,value).commit();
    }
    public static boolean getBoolean(Context context, String key , boolean defvalue){
        if(sp ==null) {
            sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        return sp.getBoolean(key,defvalue);
    }

    public static void putString(Context context, String key , String value){
        if(sp ==null) {
            sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        sp.edit().putString(key,value).commit();
    }
    public static String getString(Context context, String key , String defvalue){
        if(sp ==null) {
            sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        return sp.getString(key,defvalue);
    }

    public static void remove(Context context, String simNumber) {
        if(sp ==null) {
            sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        sp.edit().remove(simNumber).commit();
    }
}
